package com.giveu.signature.common.service;

import java.io.File;
import java.io.OutputStream;
import java.util.Map;

import com.giveu.signature.bean.TemplateHtmlParam;
import com.giveu.signature.common.service.impl.DocServiceImpl;
import com.giveu.signature.common.service.impl.HtmlServiceImpl;
import com.giveu.signature.common.service.impl.PdfServiceImpl;


public abstract class GenModelService {

	public abstract void genPdfOutputStream(OutputStream out, TemplateHtmlParam templateHtml, Map<String, Object> map)throws Exception;
	
//	public abstract File genTemlate(String templateHtml, Map<String, Object> map)throws Exception;
	
	public static GenModelService getModel(String model) {
		return GenModel.getGenService(model);
	}
	
	public enum GenModel {
		
		HTML("HTML","HTML模板生成",new HtmlServiceImpl()),
		DOC("DOC","DOC模板生成",new DocServiceImpl()),
		PDF("PDF","PDF模板生成",new PdfServiceImpl()),
		;
		String code;
		String name;
		GenModelService service;
		private GenModel(String code, String name,GenModelService service) {
			this.code = code;
			this.name = name;
			this.service = service;
		}
		public String getCode() {
			return code;
		}
		public void setCode(String code) {
			this.code = code;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public GenModelService getService() {
			return service;
		}
		public void setService(GenModelService service) {
			this.service = service;
		}
		public static GenModelService getGenService(String code) {
			for (GenModel genModel : GenModel.values()) {
				if(genModel.code.equals(code)){
					return genModel.service;
				}
			}
			throw new RuntimeException("生成服务不存在");
		}
		
	}
}
